package com.ycl.gatewayservice.filter;

import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component;

@Component
public class HelloGatewayFilterFactory extends AbstractGatewayFilterFactory<HelloGatewayFilterFactory.Config> {


    public HelloGatewayFilterFactory() {
        super(Config.class);
    }
    @Override
    public GatewayFilter apply(Config config) {
        return (exchange, chain) -> {
            System.out.println("HelloGatewayFilterFactory..."+config.getNickname());
            return chain.filter(exchange);
        };
    }
    public static class Config {
        // Put the configuration properties

        private String nickname;

        public String getNickname() {
            return nickname;
        }

        public void setNickname(String nickname) {
            this.nickname = nickname;
        }
    }

}
